<template>
  <div class="app-container" ref="content">
    <div style="text-align: center;padding: 10px">设备维保周期《{{cycleInfo.name}}》-详情信息</div>
    <el-row :gutter="10">
      <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
        <el-form :model="cycleInfo" ref="cycleInfo" label-width="100px">
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
            <el-form-item label="名称" prop="name">
              {{cycleInfo.name}}
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
            <el-form-item label="维保周期" prop="cycle">
              {{cycleFormat(cycleInfo.cycle)}}
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
            <el-form-item label="完成率" prop="percent">
              {{cycleInfo.percent}}
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8">
            <el-form-item label="描述" prop="described">
              {{cycleInfo.described}}
            </el-form-item>
          </el-col>
        </el-form>
      </el-col>
      <div style="text-align: center" class="dialog-footer">
        <el-button @click="cancelCycle">返 回</el-button>
      </div>
    </el-row>
  </div>
</template>

<script>
import {getInCycle} from "@/api/cycle";
export default {
  name: "info",
  data(){
    return{
      cycleInfo:{

      },
      scycleOptions: []
    }
  },
  created() {
    this.$nextTick(() => {
      this.getCycle(this.$route.params.ucId)

      this.getDicts("cycle_type").then(response => {
        this.scycleOptions = response.data.data;
      });
    });
  },
  methods:{
    // 状态字典翻译
    cycleFormat(value, column) {
      return this.selectDictLabel(this.scycleOptions, value);
    },
    cancelCycle(){
      window.history.back()
    },
    getCycle(value){
      //获取企业信息数据
      let loadingInstance = this.$loading({
        target:this.$refs.content,
        text:'数据加载中'
      });

      getInCycle(value).then(res => {
        this.cycleInfo = res.data.data
        loadingInstance.close()
        this.$notify.success({
          title: '成功',
          message: "获取设备维保周期信息成功"
        })
      }).catch(res => {
        loadingInstance.close()
        this.$notify.error({
          title: '失败',
          message: "获取设备维保周期信息失败"
        })
      })
    }

  }

}
</script>
